<template>
    <div class="xl-table">
        <xlUntil text="创业导师" :queryParam="queryParam" :add-btn="true" :untilVisible="false" @addForm="addForm" @delBatch="delBatch" @searchKeyWord="searchKeyWord" :searchColumns="columns"></xlUntil>
        <div class="xl-table-content">
            <xlTable
                    :columns="columns"
                    :dataSource="data"
                    rowKey="id"
                    :pagination="pagination"
                    :loading="loading"
                    @change="handleTableChange"
                    bordered
                    :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
                >
                <template v-slot:action="scope">
                    <a  @click="seeForm(scope.record)">查看</a>
                    <!-- <a-divider type="vertical"/>
                    <a-dropdown>
                        <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
                        <a-menu slot="overlay">
                            <a-menu-item @click="seeForm(scope.record)">
                                <a>查看</a>
                            </a-menu-item>
                            <a-menu-item>
                                <a-popconfirm title="确定删除吗?" @confirm="() => delForm(scope.record.id)">
                                    <a>删除</a>
                                </a-popconfirm>
                            </a-menu-item>
                        </a-menu>
                    </a-dropdown> -->
                </template>
                <template v-slot:download="scope">
                    <a :href="scope.record.materialPath" target="_blank" v-if="scope.record.materialPath">查看文件</a>
                    <span v-else>暂无文件</span>
                </template>
            </xlTable>
        </div>
        <xlForm :column="2" ref="xlForm" @handleOk="handleOk"></xlForm>
        <seeForm ref="seeForm"></seeForm>
    </div>
</template>

<script>
    import xlForm from './model/form'
    import xlMixin from '@/components/mixin/index'
    export default {
        name: "index",
        mixins:[xlMixin],
        data(){
            return{
                columns:[
                    {
                        title: '序号',
                        key: 'rowIndex',
                        align: "center",
                        fixed: 'left',
                        width:'100px',
                        sorter: (a) => a.id,//排序
                        customRender: function (t, r, index) {
                            return parseInt(index) + 1;
                        }
                    },
                    {
                        title: '导师姓名',
                        fixed: 'left',
                        width:'200px',
                        dataIndex: 'teacherName',
                        type:'input'
                    },
                    {
                        title: '是否有附件',//排序
                        width:'170px',
                        formVisible:true,
                        searchVisible:true,
                        scopedSlots: {customRender: 'download'},
                    },
                    {
                        title: '专业领域',
                        dataIndex: 'teacherDomain',
                        type:'input',
                        required:false
                    },
                    {
                        title: '工作单位',
                        dataIndex: 'teachingCompanyName',
                        type:'input',
                        required:false
                    },
                     {
                        title: '聘用时间',
                        dataIndex: 'joinDate',
                        type:'date',
                        required:false
                    },
                    {
                        title: '离开时间',
                        dataIndex: 'leaveDate',
                        type:'date',
                        required:false
                    },
                     {
                        title: '是否有聘书',
                        dataIndex: 'isContractFlag',
                        type:'radio',
                        required:false,
                        typeData:[
                            {
                                dataName:'是',
                                dataValue:true
                            },
                            {
                                dataName:'否',
                                dataValue:false
                            }
                        ]
                    },
                    {
                        title: '导师方向',
                        dataIndex: 'teacherTitle',
                        type:'input',
                        required:false,
                        searchVisible:true,
                        span:2
                    },
                    // {
                    //     title: '受聘载体',
                    //     dataIndex: 'carrierName',
                    //     type:'select',
                    //     typeData:[
                    //         {
                    //             dataName:'受聘载体1',
                    //             dataValue:'受聘载体1'
                    //         },
                    //         {
                    //             dataName:'受聘载体2',
                    //             dataValue:'受聘载体2'
                    //         }
                    //     ]
                    // },
                    {
                        title: '辅导业绩简介',
                        dataIndex: 'teachingIntroduce',
                        tableVisible:true,
                        type:'textarea',
                        required:false,
                        span:2,
                        searchVisible:true
                    },
                    {
                        title: '附件',
                        dataIndex: 'materialPath',
                        type:'upload.file',
                        tableVisible:true,
                        required:false,
                        fileTitle:{
                            titleVisible:true,
                            title:"上传导师介绍及聘用文件等证明材料"
                        },
                        span:2,
                        searchVisible:true
                    },
                    {
                        title: '操作',
                        dataIndex: 'action',
                        align: "center",
                        fixed: 'right',
                        width:'150px',
                        scopedSlots: {customRender: 'action'},
                    }
                ],
                url: {
                    list: "/system/api/carrierTeacher/pageList",
                    add: '/system/api/carrierTeacher/add',
                    edit: '/system/api/carrierTeacher/update',
                    delete: "/system/api/carrierTeacher/remove",
                    deleteBatch: "/system/api/carrierTeacher/remove",
                    exportXlsUrl: "/system/api/carrierTeacher/exportExcel",
                    importExcelUrl: "/system/api/carrierTeacher/importExcel",
                    importExcelDemoUrl: "/system/api/carrierTeacher/importTemplate"
                }
            }
        },
        components: {
            xlForm
        },
        created(){
            this.formatMerge()
            this.pageOnload()
        },
        methods:{
            addForm() {
                this.$refs.xlForm.tableTitle = '新增1'
                this.$refs.xlForm.visible = true
                this.$refs.xlForm.confirmLoading = false
                this.$refs.xlForm.formatForm({})
                this.$refs.xlForm.type = 1
            }
        }
    }
</script>

<style scoped lang="less">
    .xl-table{
        .xl-table-content{
            padding: 16px;
        }
    }
</style>
